package com.collins.thread.practices.restaurantQueue;

import java.util.concurrent.ArrayBlockingQueue;

public class Consumer implements Runnable {

    private ArrayBlockingQueue<String> queue;

    public Consumer(ArrayBlockingQueue<String> queue) {
        this.queue = queue;
    }

    @Override
    public void run() {
        while(true){
            try {
                String product = queue.take();
                System.out.println(Thread.currentThread().getName() + " consume one product: " + product);
            } catch (InterruptedException e) {
                throw new RuntimeException(e);
            }

        }
    }
}
